package com.tips {
	import com.bases.TUIComponent;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;

	/**
	 * [目前该只采用垂直布局]
	 * @author tamt
	 */
	public class TipPanelContent extends  Sprite {
		protected var gap : uint = 0;

		public function TipPanelContent(autoDispose : Boolean = true) {
		}

		public function onDock() : void {
		}

		public function onUnDock() : void {
		}

		override public function addChild(child : DisplayObject) : DisplayObject {
			var ret : DisplayObject = super.addChild(child);
			this.relayout(child);
			return ret;
		}

		override public function removeChild(child : DisplayObject) : DisplayObject {
			var ret : DisplayObject = super.removeChild(child);
			this.relayout();
			return ret;
		}

		/**
		 * 重新布局.
		 */
		protected function relayout(child : DisplayObject = null) : void {
			var num : int = this.numChildren;
			var prechild : DisplayObject;
			var i : int = child == null ? 0 : this.getChildIndex(child);
			for(;i < num;i++) {
				if(i == 0) {
					this.getChildAt(i).y = 0;
				} else {
					prechild = this.getChildAt(i - 1);
					this.getChildAt(i).y = prechild.y + prechild.height + this.gap;
				}
			}
			
			dispatchEvent(new Event(Event.RESIZE, true, true));
		}

		/**
		 * 销毁
		 */
		public function dispose() : void {
		}
	}
}
